<template>
    <div>
        <div>
            <table-data
                    :ref="tableToolName"
                    :form="formId"
                    :table-data="list"
                    :total="total"
                    :extend-tools="extendHeaders"
                    :show-create="showCreate"
                    :show-edit="showEdit"
                    @on-page-change="handlePageChange"
                    @on-page-size-change="handlePageSizeChange"
                    @on-form-create-click="handlerFormCreate"
                    @on-form-update-click="handlerFormUpdate"
                    @on-delete="handlerItemDelete"
                    @on-filter-event="handleFilterEvent"
                    @before-form-open="handlerItemBeforeFormOpen"
                    @on-get-auth-login-page-url="handlerGetAuthLoginPageUrl"
                    :is-show-filter-form="isShowFilterForm"
                    :filter-form-rule="filterFormRule"
                    @on-update-btn-click="handleOUpdateAndDetailBtnClick"
                    @on-create-btn-click="handleOCreateBtnClick"
                    @on-detail-btn-click="handleOUpdateAndDetailBtnClick"
                    @on-publish-mini-program="handleOnPublishMiniProgram"
                    @on-mini-program-operation-record="handleShowOperateRecord"
                    @on-update-domain="handleOpenCustomizeUpdateDomain"
                    @on-get-experience-qr-code="handleOpenExperienceQrCode"
                    @on-update-audit-item-list="handleOpenCustomizeUpdateAuditItemList"
                    @on-revert-code-release="handleOnRevertCodeRelease"
                    @on-get-latest-audit-status="handleOnGetLatestAuditStatus"
                    @on-mini-program-code-commit="handleOnMiniProgramCodeCommit"
                    @on-mini-program-submit-audit="handleOnMiniProgramSubmitAudit"
                    @on-mini-program-withdraw-audit="handleOnMiniProgramWithdrawAudit"
                    @on-mini-program-release="handleOnMiniProgramRelease"
                    @on-speed-up-audit="handleOnSpeedUpAudit"
                    @on-get-month-submit-limit-info="handleGetMonthSubmitLimitInfo"
                    @on-set-privacy="handleSetPrivacy"
                    @on-get-privacy="handleGetPrivacy"
            >

                <template slot="extFormHeaderContent">
                    <div>
                        <span style="position: absolute;margin-left: 95px">ext_json</span>
                        <Card class="appProjectListExtJson" style="margin-bottom: 15px; margin-left: 150px">
                            <JsonEditor
                                    :options="{
                                            confirmText: '确认',
                                            cancelText: '取消',
                                        }"
                                    :objData="extForm.data.ext_json"
                                    v-model="extForm.data.ext_json">
                            </JsonEditor>
                        </Card>
                    </div>
                    <div>
                        <Form v-if="extForm.showSwitch" :ref="extForm.name" :model="extForm.data" :rules="extForm.ruleInline" :label-width="125" style="padding: 0 25px;">
                            <!--额外字段插槽-->
                            <FormItem label="项目类型" prop="app_project_type_id">
                                <Select v-model="extForm.data.app_project_type_id" placeholder="项目类型" @on-change="handlerAppProjectTypeSelect">
                                    <Option v-for="(itemOption, itemIndex) in extForm.selectData.appProjectTypeList" :value="itemOption.id" :key="itemIndex">{{itemOption.name}}</Option>
                                </Select>
                            </FormItem>

                            <FormItem label="模板选择" prop="mpt_id">
                                <Select v-model="extForm.data.mpt_id" placeholder="模板选择" @on-change="handlerTemplateSelect">
                                    <Option v-for="(itemOption, itemIndex) in extForm.selectData.mptList" :value="itemOption.id" :key="itemIndex">{{itemOption.name}}</Option>
                                </Select>

                            </FormItem>

                            <FormItem>
                                <img v-for="(imageItem) in extForm.templateImages" :src="imageItem" alt="" style="margin-left: 10px; width: 80px; height: 80px" @click="handleImageClick(imageItem)">
                            </FormItem>

                            <FormItem style="display: none">
                                <Button ref="extFormSubmitBtn" type="primary" @click="()=>{}">Submit</Button>
                            </FormItem>
                        </Form>
                    </div>

                </template>

            </table-data>

            <Modal
                    v-model="imageClick.visible"
                    title="预览"
                    :footer-hide="imageClick.footHide">
                <img :src="imageClick.src" style="width: 100%;">
            </Modal>

            <!--操作记录查看-->
            <Modal
                    v-model="operationRecordSetting.visible"
                    title="操作记录列表"
                    :footer-hide=false
                    @on-ok="() => {}"
                    width="80%"
                    :styles="{top:'10px'}"
            >
                <operation-record v-if="operationRecordSetting.visible" :ap-id="operationRecordSetting.apId"></operation-record>
            </Modal>

            <Modal
                    v-model="customizeUpdateDomain.visible"
                    title="更新服务器域名或业务域名"
                    :footer-hide=true
                    @on-ok="() => {}">
                <div>
                    说明：<br>
                    该设置会拼接 模板与项目类型 相关【更新服务器域名或业务域名】配置。<br>
                    除非需要给该项目特殊设置，否则无需配置。<br>
                    请正确配置 模板与项目类型 相关【更新服务器域名或业务域名】。<br>
                </div>
                <set-domain @on-close-customize-update="handleCloseCustomizeUpdateDomain"
                            @on-get-domain-data="handleUpdateDomain"
                            v-if="customizeUpdateDomain.visible"
                            :syc-button-visible="customizeUpdateDomain.synButtonVisible"
                            :id="customizeUpdateDomain.id"
                            :data="customizeUpdateDomain.data">
                </set-domain>
            </Modal>

            <Modal
                    v-model="experienceQrCode.visible"
                    title="体验版二维码"
                    :footer-hide="experienceQrCode.footHide">
                <img :src="experienceQrCode.url" style="width: 100%;" id="img">
            </Modal>

            <Modal
                    v-model="customizeUpdateAuditItemList.visible"
                    title="修改审核项列表"
                    :footer-hide=true
                    width="1000"
                    @on-ok="() => {}">
                <jsonConfigObject
                        :key-name="customizeUpdateAuditItemList.name"
                        v-if="customizeUpdateAuditItemList.visible"
                        :json-data="customizeUpdateAuditItemList.data"
                        ref="customizeUpdateAuditItemList"
                >
                </jsonConfigObject>
                <div style="margin-left: 180px">
                    <Button type="primary" @click="handleSubmitUpdateAuditItemList">提交</Button>
                    <Button @click="handleResetUpdateAuditItemList" style="margin-left: 8px">重置</Button>
                </div>
            </Modal>

            <!--加急审核申请-->
            <Modal
                    v-model="speedUpAuditPop.visible"
                    :title="speedUpAuditPop.title"
                    :footer-hide="true">
                <div>
                    <Input v-model="speedUpAuditPop.auditId" :placeholder="speedUpAuditPop.auditInputTip">
                        <span slot="prepend" :title="speedUpAuditPop.auditInputTip">审核单ID</span>
                        <span slot="append" @click="handleOnSpeedUpAuditPost" style="cursor: pointer;" title="点击提交加急审核申请">提交加急</span>
                    </Input>
                </div>
            </Modal>

        </div>
    </div>
</template>

<script>
    import {mapState, mapActions} from 'vuex';
    import TableData from '../../table/components/TableData';
    import formconfig from '../../config/form';
    import pageconfig from '../../table/configs/pageconfig';
    import OperationRecord from '../wechat/miniProgramOperationRecordPage';
    import setDomain from "../components/setServerAndWebViewDomainForm";
    import jsonConfigObject from "../components/jsonConfigObject";

    import apiService from '../../api/appProjectList';
    import {forEach} from "../../libs/tools";

    let formId        = formconfig.APP_PROJECT_LIST_FORM_ID;
    let pageRequestFn = apiService.appProjectListPage;

    export default {
        name      : 'appProjectListPage',
        components: {
            TableData, OperationRecord, setDomain, jsonConfigObject
        },
        computed  : {
            ...mapState({
                token: state => state.user.token,
            }),
        },
        watch     : {
            page(newVal, oldVal) {
                this._setTablePage(newVal);
            },
        },
        methods   : {
            handlePageSizeChange(pageSize) {
                this.page     = 1;
                this.per_page = pageSize;
                this.refreshData();
            },
            handleFilterEvent(conditions) {
                this.conditions = conditions;
                this.page       = 1;
                this.refreshData();
            },
            handlePageChange(page) {
                this.page = page;
                this.refreshData();
            },
            refreshData() {//刷新页面
                this.pageRequestHandler(
                    pageRequestFn({
                        page_info : {
                            page    : this.page,
                            per_page: this.per_page
                        },
                        conditions: this.conditions
                    }),
                    (data) => {
                        //获取列表数据
                        this.list  = data.list;
                        this.total = data.total_count;
                        this._clearSelectNum();
                    }
                );
            },
            handlerFormCreate(data, close) {//新建表单提交，close为关闭表单弹窗函数
                this.operatorRequestHandler(
                    apiService.appProjectStore(Object.assign({},data,this.extForm.data)),
                    (res) => {
                        close();
                        this.page = 1;
                        this.refreshData();
                    },
                );
            },
            handlerFormUpdate(data, id, close) {//更新表单提交,close为关闭表单弹窗函数
                this.operatorRequestHandler(
                    apiService.appProjectUpdate(id, Object.assign({}, data, this.extForm.data)),
                    (res) => {
                        close();
                        this.refreshData();
                    },
                );
            },
            handlerItemDelete(data) {//删除条目
                this.popConfirm(
                    () => {
                        this.operatorRequestHandler(
                            apiService.appProjectDelete(data.id),
                            (data) => {
                                this.refreshData();
                            },
                            null,
                            null
                        );
                    },
                );
            },
            _clearSelectNum() {//清空表格选中条目
                this.$refs[this.tableToolName] && (this.$refs[this.tableToolName].selectNum = 0);
            },
            _setTablePage(page) {//设置表格分页
                this.$refs[this.tableToolName] && (this.$refs[this.tableToolName].page = page);
            },
            handlerItemBeforeFormOpen(data, setCustomProps) {//表单打开前的操作，setCustomProps为设置表单中字段额外信息
                //e.g 设置表单字段的额外属性,如投片上传接口，添加token头部信息
                //fixme xinya-table中有个bug,如果设置了头部，则在修改表单中，关于时间的字段都显示为空
                data && setCustomProps([
                    {
                        field_name : 'head_img',//指定字段
                        field_props: {
                            data   : {},//请求附带参数,上传照片附带骑手id
                            headers: {//验证头部
                                Authorization   : this.token,
                                Accept          : 'application/vnd.app.v1+json',
                                ContentType     : 'application/json'
                            },
                        }
                    },
                ]);
            },
            handlerGetAuthLoginPageUrl(data) {
                console.log('输出',data);
                this.operatorRequestHandler(
                    apiService.appProjectGetAuthLoginPageUrl(data.id),
                    (res) => {
                        console.log('返回结果:', res);
                        this.popConfirm(
                            () => {
                                window.open(res.data.component_login_page_url);
                            },
                            '跳转确认到授权页面',
                            '确认跳转到授权页面吗？',
                            null,
                        );
                    },
                );
            },
            handleOUpdateAndDetailBtnClick(rowData) {//点击更新或者详情按钮
                this.cleanExtFormData();

                this.extForm.data.app_project_type_id = rowData.app_project_type_id;
                this.extForm.data.mpt_id              = rowData.mpt_id;
                this.extForm.data.ext_json            = rowData.ext_json.length == 0 ? {} : rowData.ext_json;
                //获取分类信息和模板信息
                this.appProjectTypeGet();
                this.appProjectMiniProgramTemplate(rowData.app_project_type_id, rowData.mpt_id);

                this.extFormShow();
            },
            handleOCreateBtnClick() {//点击新建按钮
                this.extFormShow();
                this.cleanExtFormData();

                this.appProjectTypeGet();
            },
            extFormShow() {//xinya-table额外字段表单展示
                this.extForm.showSwitch = false;

                this.$nextTick(() => {
                    this.extForm.showSwitch = true;
                });
            },
            appProjectTypeGet() {//获取项目类型
                this.operatorRequestHandler(
                    apiService.appProjectTypeGet({}),
                    (data) => {
                        this.extForm.selectData.appProjectTypeList = data.data;
                    },
                    null,
                    null
                );
            },
            appProjectMiniProgramTemplate(typeId, $mptIdToImages = null) {//获取对应类型模板列表供选择使用, 存在$mptIdToImages就赋值图片
                this.operatorRequestHandler(
                    apiService.appProjectMiniProgramTemplate(typeId),
                    (data) => {
                        this.extForm.selectData.mptList = data.data;
                        if ($mptIdToImages !== null) {
                            let mptIndex = this.findFieldValInObj(data.data, 'id', $mptIdToImages);
                            this.extForm.templateImages = data.data[mptIndex]['images'];
                        }
                    },
                    null,
                    null
                );
            },
            handlerAppProjectTypeSelect(typeId) {//类型选项修改触发
                //清空模板选项
                this.extForm.selectData.mptList = [];
                this.extForm.data.mpt_id        = null;
                this.extForm.templateImages     = [];

                //获取对应类型魔板列表
                this.appProjectMiniProgramTemplate(typeId);
            },
            handlerTemplateSelect(templateId) {
                if (templateId !== undefined) {
                    let templateIndex = this.findFieldValInObj(this.extForm.selectData.mptList, 'id', templateId);
                    this.extForm.templateImages = this.extForm.selectData.mptList[templateIndex]['images'];
                }
            },
            /**
             * 通过数组的id值返回索引
             * 条件为true时，返回索引；否则返回-1
             */
            findFieldValInObj(arr, key, value) {
                return arr.findIndex(res => res[key] === value);
            },
            handleImageClick(imageSrc) {
                this.imageClick.visible = true;
                this.imageClick.src = imageSrc;
            },
            handleOnPublishMiniProgram(data){//小程序发布
              if(data.length>1){
                var that=this;
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.appProjectProjectPublishMiniProgram(item.id),
                        (data) => {

                        },
                        null
                      );
                    });
                  },
                  '操作确认',
                  '确认发布该项目小程序上线吗？(本操作将会【上传小程序代码】并【提交审核】，审核需要一定时间，请耐心等待，项目设置 “审核通过自动发布已通过审核的小程序” 为 “启用”，审核成功后系统将【发布已通过审核的小程序】)',
                );
              }else{
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.appProjectProjectPublishMiniProgram(data.id),
                      (data) => {

                      },
                      null
                    );
                  },
                  '操作确认',
                  '确认发布该项目小程序上线吗？(本操作将会【上传小程序代码】并【提交审核】，审核需要一定时间，请耐心等待，项目设置 “审核通过自动发布已通过审核的小程序” 为 “启用”，审核成功后系统将【发布已通过审核的小程序】)',
                );

              }
            },
            handleShowOperateRecord(data) {
                this.operationRecordSetting.visible = true;
                this.operationRecordSetting.apId    = data.id;
            },
            cleanExtFormData(){//清除
                this.extForm.data.app_project_type_id      = null;
                this.extForm.data.mpt_id                   = null;
                this.extForm.data.ext_json                 = {};
                this.extForm.selectData.mptList            = [];
                this.extForm.selectData.appProjectTypeList = [];
                this.extForm.templateImages                = [];
            },

            //修改服务器域名或业务域名
            handleOpenCustomizeUpdateDomain(data) {
                this.customizeUpdateDomain.visible = true;
                this.customizeUpdateDomain.id = data.id;
                this.customizeUpdateDomain.data = {
                    'server_domain': data.server_domain,
                    'webviewdomain': data.webviewdomain
                };
            },
            handleCloseCustomizeUpdateDomain() {
                this.customizeUpdateDomain.visible = false;
                this.customizeUpdateDomain.id = null;
                this.customizeUpdateDomain.data = null;
                this.refreshData();
                this._clearSelectNum();
            },
            handleUpdateDomain(data) {
                this.operatorRequestHandler(
                    apiService.appProjectUpdateDomain(this.customizeUpdateDomain.id, data),
                    () => {
                        this.handleCloseCustomizeUpdateDomain();
                    }
                )
            },
            handleOpenExperienceQrCode(data) {
                this.popConfirm(
                    () => {
                        this.operatorRequestHandler(
                            apiService.appProjectExperienceQrCode(data.id),
                            (res) => {
                                this.experienceQrCode.url = URL.createObjectURL(res);
                                this.experienceQrCode.visible = true;
                            },
                            null,
                            '操作成功',
                            true,
                            true
                        )
                    },
                    '提示',
                    '是否获取体验版二维码',
                );
            },
            //修改审核项列表
            handleOpenCustomizeUpdateAuditItemList(data) {
                this.customizeUpdateAuditItemList.visible = true;
                this.customizeUpdateAuditItemList.id = data.id;
                this.customizeUpdateAuditItemList.data = data.wx_submit_audit_item_list;
            },
            handleCloseCustomizeUpdateAuditItemList() {
                this.customizeUpdateAuditItemList.visible = false;
                this.customizeUpdateAuditItemList.id = null;
                this.customizeUpdateAuditItemList.data = null;
                this.refreshData();
                this._clearSelectNum();
            },
            handleSubmitUpdateAuditItemList() {
                let data = {
                    'wx_submit_audit_item_list' : this.$refs.customizeUpdateAuditItemList.handleCreateObject()
                };
                this.operatorRequestHandler(
                    apiService.appProjectUpdateAuditItemList(this.customizeUpdateAuditItemList.id, data),
                    () => {
                        this.handleCloseCustomizeUpdateAuditItemList();
                    }
                )
            },
            handleResetUpdateAuditItemList() {
                this.$refs.customizeUpdateAuditItemList.handleRemoveAll();
            },
            handleOnRevertCodeRelease(data) {//回退小程序版本
              if(data.length>1){//data为集合
                var that=this;
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.revertCodeRelease(item.id),
                        (res) => {

                        },
                        null,
                        '操作成功',
                      );
                    });
                  },
                  '操作确认',
                  '确认回退小程序版本吗？',
                );
              }else {
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.revertCodeRelease(data.id),
                      (res) => {

                      },
                      null,
                      '操作成功',
                    );
                  },
                  '操作确认',
                  '确认回退小程序版本吗？',
                );
              }
            },
            handleOnGetLatestAuditStatus(data) {//查询最新一次提交的审核状态
                var resultTipPre = '查询最新一次提交的审核状态结果：';
                this.popConfirm(
                    () => {
                        this.operatorRequestHandler(
                            apiService.getLatestAuditStatus(data.id),
                            (res) => {
                                if (res.data.errcode == 0) {
                                    this.refreshData();
                                    this._clearSelectNum();
                                    switch (res.data.status) {
                                        case 0:
                                            this.messageTip(resultTipPre + '审核成功');
                                            break;
                                        case 1:
                                            this.messageTip(
                                                resultTipPre + `审核被拒绝,拒绝原因：${res.data.reason}, 最新的审核 ID: ${res.data.auditid}, 审核失败的小程序截图示例：${res.data.ScreenShot}`,
                                                60,
                                            );
                                            break;
                                        case 2:
                                            this.messageTip(resultTipPre + '审核中' + (res.data.auditid ? `,审核 ID: ${res.data.auditid}` : ''));
                                            break;
                                        case 3:
                                            this.messageTip(resultTipPre + '已撤回');
                                            break;
                                    }
                                } else if (res.data.errcode == -1) {
                                    this.$Message.error(resultTipPre + '系统繁忙');
                                } else if (res.data.errcode == 86000) {
                                    this.$Message.error(resultTipPre + '不是由第三方代小程序进行调用');
                                } else if (res.data.errcode == 86001) {
                                    this.$Message.error(resultTipPre + '不存在第三方的已经提交的代码');
                                } else if (res.data.errcode == 85012) {
                                    this.$Message.error(resultTipPre + '无效的审核 id');
                                }
                            },
                            null,
                            null,
                        );
                    },
                    '操作确认',
                    '确认查询最新一次提交的审核状态吗？',
                );
            },
            messageTip(content, duration = 15, closable = true) {//弹出提示
                this.$Message.info({
                    content : content,
                    duration: duration,
                    closable: closable
                });
            },
            handleOnMiniProgramCodeCommit(data) {//上传小程序代码
              if(data.length>1){//data为集合
                var that=this;
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.codeCommit(item.id),
                        (res) => {

                        },
                        null,
                        '操作成功',
                      );
                    });
                  },
                  '操作确认',
                  '确认上传小程序代码吗？',
                );
              }else{
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.codeCommit(data.id),
                      (res) => {

                      },
                      null,
                      '操作成功',
                    );
                  },
                  '操作确认',
                  '确认上传小程序代码吗？',
                );
              }
            },
            handleOnMiniProgramSubmitAudit(data) {//小程序提交审核
              if(data.length>1){
                var that=this;
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.miniProgramSubmitAudit(item.id),
                        (res) => {

                        },
                        null,
                        '操作成功',
                      );
                    })
                  },
                  '操作确认',
                  '确认小程序提交审核吗？(审核时间可能较长，提交后请耐心等待，提交审核如果成功，如果项目设置 “审核通过自动发布已通过审核的小程序” 为 “启用”，系统将直接【发布已通过审核的小程序---发布最后一个审核通过的小程序代码版本】)',
                );
              }else {
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.miniProgramSubmitAudit(data.id),
                      (res) => {

                      },
                      null,
                      '操作成功',
                    );
                  },
                  '操作确认',
                  '确认小程序提交审核吗？(审核时间可能较长，提交后请耐心等待，提交审核如果成功，如果项目设置 “审核通过自动发布已通过审核的小程序” 为 “启用”，系统将直接【发布已通过审核的小程序---发布最后一个审核通过的小程序代码版本】)',
                );
              }

            },
            handleOnMiniProgramWithdrawAudit(data) {//小程序审核撤回
              if(data.length>1){
                var that = this;
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.miniProgramWithdrawAudit(item.id),
                        (res) => {

                        },
                        null,
                        '操作成功',
                      );
                    });
                  },
                  '操作确认',
                  '确认小程序审核撤回吗？',
                );
              }else{
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.miniProgramWithdrawAudit(data.id),
                      (res) => {

                      },
                      null,
                      '操作成功',
                    );
                  },
                  '操作确认',
                  '确认小程序审核撤回吗？',
                );
              }
            },
            handleOnMiniProgramRelease(data) {//发布已通过审核的小程序
              var that=this;
              if(data.length>1){
                that.popConfirm(
                  () => {
                    data.forEach(function(item, index) {
                      that.operatorRequestHandler(
                        apiService.miniProgramRelease(item.id),
                        (res) => {

                        },
                        null,
                        '操作成功',
                      );
                    });
                  },
                  '操作确认',
                  '确认发布已通过审核的小程序吗？',
                );
              }else{
                this.popConfirm(
                  () => {
                    this.operatorRequestHandler(
                      apiService.miniProgramRelease(data.id),
                      (res) => {

                      },
                      null,
                      '操作成功',
                    );
                  },
                  '操作确认',
                  '确认发布已通过审核的小程序吗？',
                );
              }
            },
            handleOnSpeedUpAuditPost() {},//加急审核申请提交，被改写
            handleOnSpeedUpAudit(data) {//加急审核申请弹出
                this.speedUpAuditPop.visible = true;
                this.speedUpAuditPop.auditId = '';

                this.handleOnSpeedUpAuditPost = () => {
                    if (!this.speedUpAuditPop.auditId.replace(new RegExp(/( )/g), '')) {
                        this.speedUpAuditPop.auditId = '';
                        return false;
                    }
                    this.popConfirm(
                        () => {
                            this.operatorRequestHandler(
                                apiService.speedUpAudit(data.id, this.speedUpAuditPop.auditId),
                                (res) => {

                                },
                                null,
                                '操作成功',
                            );
                        },
                        '操作确认',
                        '确认加急审核申请吗？',
                    );
                };
            },
            handleGetMonthSubmitLimitInfo(data){//查询服务商的当月提审限额（quota）和加急次数
                this.operatorRequestHandler(
                    apiService.getMonthSubmitLimitInfo(data.id),
                    (res) => {
                        let tip = `平台总提交限制：${res.data.limit}；\r\n平台提交剩余次数：${res.data.rest}；剩余加急次数：${res.data.speedup_limit}；当月分配加急次数：${res.data.speedup_rest};（所有旗下小程序共用该额度）`;
                        this.popConfirm(
                            () => {},
                            '操作成功',
                            tip,
                            null,
                            'success'
                        );
                    },
                    null,
                    null,
                );
            },
          handleSetPrivacy(data){//配置小程序用户隐私保护指引
            this.popConfirm(
              () => {
                this.operatorRequestHandler(
                  apiService.appSetMiniProgramPrivacy(data.id),
                  (data) => {

                  },
                  null
                );
              },
              '操作确认',
              '确认配置小程序用户隐私保护指引吗？',
            );
          },
          handleGetPrivacy(data){//查询配置小程序用户隐私保护指引
            this.operatorRequestHandler(
              apiService.getMiniProgramPrivacy(data.id),
              (res) => {
                let tip = JSON.stringify(res.data);
                this.popConfirm(
                  () => {},
                  '操作成功',
                  tip,
                  null,
                  'success'
                );
              },
              null,
              null,
            );
          },
        },
        data() {
            return {
                formId       : formId,
                extendHeaders: [
                    {
                        name : '修改审核项列表',//操作名称
                        event: 'on-update-audit-item-list',//操作点击事件
                        show : (selectNum, dataInfo) => {//显示操作按钮的条件方法
                            return selectNum === 1;
                        }
                    },
                    {
                        name : '修改服务器域名及业务域名',//操作名称
                        event: 'on-update-domain',//操作点击事件
                        show : (selectNum, dataInfo) => {//显示操作按钮的条件方法
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                        }
                    },
                    {
                        name : '删除',//操作名称
                        event: 'on-delete',//操作点击事件
                        show : (selectNum, dataInfo) => {//显示操作按钮的条件方法
                            return selectNum === 1;
                        }
                    },
                    {
                        name : '授权页面获取',//操作名称
                        event: 'on-get-auth-login-page-url',//操作点击事件
                        show : (selectNum, dataInfo) => {//显示操作按钮的条件方法
                            return selectNum === 1;
                        }
                    },
                    {
                        name : '上传小程序代码',
                        event: 'on-mini-program-code-commit',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '小程序提交审核',
                        event: 'on-mini-program-submit-audit',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '小程序审核撤回',
                        event: 'on-mini-program-withdraw-audit',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '发布已通过审核的小程序',
                        event: 'on-mini-program-release',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '操作记录',
                        event: 'on-mini-program-operation-record',
                        show : (selectNum, dataInfo) => {
                            return selectNum === 1;
                        }
                    },
                    {
                        name : '获取体验版二维码',
                        event: 'on-get-experience-qr-code',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                        }
                    },
                    {
                        name : '小程序版本回退',
                        event: 'on-revert-code-release',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '查询最新一次提交的审核状态',
                        event: 'on-get-latest-audit-status',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                        }
                    },
                    {
                        name : '一键发布',
                        event: 'on-publish-mini-program',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum > 0;
                        }
                    },
                    {
                        name : '加急审核申请',
                        event: 'on-speed-up-audit',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                        }
                    },
                    {
                        name : '当月提审限额（quota）和加急次数情况',
                        event: 'on-get-month-submit-limit-info',
                        show : (selectNum, dataInfo) => {
                            return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                        }
                    },
                  {
                    name : '配置小程序隐私',
                    event: 'on-set-privacy',
                    show : (selectNum, dataInfo) => {
                      return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                    }
                  },
                  {
                    name : '查询小程序隐私配置',
                    event: 'on-get-privacy',
                    show : (selectNum, dataInfo) => {
                      return dataInfo.auth_status == 1 && dataInfo.status == 1 && selectNum === 1;
                    }
                  },
                ],
                showCreate   : true,
                showEdit     : true,
                page         : 1,
                per_page     : pageconfig.DEFAULT_PAGE_SIZE,
                conditions   : [],
                list         : [],
                total        : 0,
                tableToolName: 'tableTool',
                //过滤表单配置
                isShowFilterForm: true,//是否显示过滤表单
                filterFormRule  : [//过滤表单设置
                    {
                        fieldName: 'name',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'remark',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'status',
                        fieldType: 'select',
                    },
                    {
                        fieldName: 'auth_status',
                        fieldType: 'select',
                    },
                    {
                        fieldName                 : 'mpt_id',
                        fieldType                 : 'select',
                        optionRemoteGetOnce       : true,
                        optionsRemoteDisableSwitch: true,
                        optionsRemoteUrl          : apiService.getTemplateListForSearchFilterUri,
                    },
                    {
                        fieldName                  : 'app_project_type_id',
                        fieldType                  : 'select',
                        optionRemoteGetOnce        : true,
                        optionsRemoteUrl           : apiService.getProjectTypeListUri,
                        optionsRemoteFieldNameValue: 'id',
                        optionsRemoteFieldNameLabel: 'name',
                    },

                    {
                        fieldName: 'wx_authorizer_appid',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'wx_nick_name',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'wx_principal_name',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'wx_signature',
                        fieldType: 'text',
                    },
                    {
                        fieldName: 'wx_submit_audit_item_rely_mpt',
                        fieldType: 'select',
                    },
                    {
                        fieldName: 'switch_audit_success_release',
                        fieldType: 'select',
                    },
                    {
                        fieldName: 'last_audit_status',
                        fieldType: 'select',
                    },
                  {
                    fieldName: 'auth_time',
                    fieldType: 'datetimerange',
                  },
                  {
                    fieldName  : 'created_at',//必要配置，过滤字段
                    fieldType  : 'datetimerange',//必要配置，表单字段类型
                    placeholder: '',//可选配置

                    dateFormat: 'yyyy-MM-dd HH:mm:ss',//可选配置，日期格式，默认yyyy-MM-dd HH:mm:ss
                  },
                  {
                    fieldName: 'updated_at',
                    fieldType: 'datetimerange',
                  },

                ],
                extForm: {
                    showSwitch: false,
                    name      : '',
                    data      : {
                        app_project_type_id : null,
                        mpt_id              : null,
                        ext_json            : {},
                    },
                    ruleInline: {
                        app_project_type_id: [
                            {required: true, message: '请选择分类'}
                        ],
                        mpt_id             : [
                            {required: true, message: '请选择项目模板'}
                        ],
                    },
                    selectData: {
                        appProjectTypeList: [],
                        mptList           : [],
                    },
                    templateImages: [],
                },
                imageClick: {
                    visible: false,
                    footHide: true,
                    src: ''
                },
                //操作记录
                operationRecordSetting: {
                    visible : false,
                    apId    : null,
                },
                //更改服务器域名或业务域名
                customizeUpdateDomain : {
                    visible         : false,
                    synButtonVisible: true,
                    id              : null,
                    data            : null,
                },
                //体验版二维码
                experienceQrCode: {
                    visible: false,
                    footHide: true,
                    url: null,
                },
                //修改审核项列表
                customizeUpdateAuditItemList : {
                    visible : false,
                    name    : '审核项列表',
                    id      : null,
                    data    : null,
                },
                //加急审核申请
                speedUpAuditPop: {
                    visible      : false,
                    title        : '加急审核申请',
                    auditId      : '',
                    auditInputTip: '可从 【操作记录】中获取或者 【查询最新一次提交的审核状态】 后在【操作记录】 中查看',
                },
            }
        },
        created() {
            this.refreshData();
        }
    }
</script>
<style>
    .pure-form select {
        height: 1.50rem;
    }
    .appProjectListExtJson .block_content .key-input,.appProjectListExtJson .block_content .val-input {
        width: 55px;
        border: 1px solid #dcdee2;
        border-radius: 4px;
    }

    .appProjectListExtJson:hover{
        width: 600px;
    }

    /*json编辑输入框长度样式修改*/
    .f-input {
        width: 410px;
    }

    /*json编辑下拉伸展按钮左移*/
    .collapse-down {
        position: absolute;
        left: -30px;
    }

</style>
